<?php 

if ( $_GET[md5('actionRegistro')] != "" && !$_POST ){

		$objRecorSet = $objConn->Execute('DELETE FROM tbl_curriculo_area_interesse WHERE md5(co_area_interesse) = \''.$_GET[md5('actionRegistro')].'\' 
											AND md5(co_cliente) = \''. $_SESSION[md5('codigoUsuario')]."'") ;	
		$objConn->Execute($insertSQL);									
		echo	$strMensagem =  '<h1  style="color:#FF0000">Insteresse removido com sucesso. </h1>';
}



if ( $_POST ){

	$objRecorSet = $objConn->Execute('SELECT co_codigo FROM tbl_cadastro WHERE md5(co_codigo) = \''. $_SESSION[md5('codigoUsuario')]."'" );	
	if ( $objRecorSet->_numOfRows > 0 ){	
		$codUsuario = $objRecorSet->fields['co_codigo'];
	}

	foreach ( $_POST['tpArea'] as $k => $v )
	{
		$objRecorSet = $objConn->Execute('SELECT * FROM tbl_curriculo_area_interesse WHERE co_area_interesse = '.$v.' 
											AND md5(co_cliente) = \''. $_SESSION[md5('codigoUsuario')]."'") ;	
		if ( $objRecorSet->_numOfRows == 0 ){	
			$objRegistro["co_cliente"] = $codUsuario;
			$objRegistro["co_area_interesse"] = $v;
			
			$insertSQL  =  $objConn->GetInsertSQL($objRecorSet, $objRegistro ); 
			$objConn->Execute($insertSQL);
		}
	}
	 echo	$strMensagem =  '<h1  style="color:#FF0000">Insteresse(s) cadastrado(s) com sucesso. </h1>';
}
?>  
<table width="450" cellpadding="3" cellspacing="0" border="0">
<tr>
  <td colspan="2" align="left"><img src="images/tit_areas_interesse.gif" border="0" width="243" height="23"></td>
</tr>
 
<tr>
  <td colspan="2" align="center"><font class="normal">
  
  <!-- FORMULÁRIO - ÁREAS DE INTERESSE-->
  <table width="440" cellpadding="2" cellspacing="0" border="0">
  <form name="form" action="" target="info" method="post" >
 
  <tr>
    <td width="440" class="normal" colspan="4" align="left">
	Selecione as <b>Área de Interesse</b>  e clique no 
	botão <b>cadastrar</b>. 
	<br>&nbsp;	</td>
  </tr>
  

	<tr>
		<td>
		

<div id="boxAreas" class="" style="position:relative;">
	<div class="coluna">
			
	<?php 
		$objRegistro  =  $objConn->Execute("SELECT *,DATE_FORMAT(dt_cadastro,'%d/%m/%Y %H:%i') as dt_data  
												FROM tbl_curriculo_area 
												WHERE st_status='S'
												ORDER BY no_area ASC");
		
		if( $objError->semErros() )
		{
		    
			while( !$objRegistro->EOF ) {
				echo '<strong>'.$objRegistro->fields['no_area'].'</strong><ul class="listAreas">';
				
				$objRegistroSub = $objConn->Execute("SELECT *,DATE_FORMAT(dt_cadastro,'%d/%m/%Y %H:%i') as dt_data  
												FROM tbl_curriculo_sub_area 
												WHERE st_status='S' AND co_area = ".$objRegistro->fields['co_codigo']."  
												ORDER BY no_area ASC");
				
					while( !$objRegistroSub->EOF ) {
			
						echo '<li style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; cursor: pointer; ">';
						echo '<input type="checkbox" style=" float:left;" name="tpArea[]" value="'.$objRegistroSub->fields['co_codigo'].'" id="tpArea'.$objRegistroSub->fields['co_codigo'].' ">';
						echo $objRegistroSub->fields['no_area'];
						echo '<br clear="all"></li>';

						$objRegistroSub->MoveNext();
					}
		
					echo '</ul><br>';
					
				$objRegistro->MoveNext();	
				
			}
		}	
	?>							
	</div>	
</div>		</td>
	</tr>	

    <!-- LINHA -->
  <td width="440" class="normal" colspan="4" align="right">
    <hr size="1" width="100%" noshade color="#e9e9e9">  </td>
    <!-- fim de LINHA -->	
  </tr>
 
  <tr>
    <!-- BOTÕES -->
  <td width="440" class="normal" colspan="4" align="right">
    <input type="submit" name="cadastrar" value="cadastrar" class="button">&nbsp;</td>
    <!-- fim de BOTÕES -->	
  </tr>
  
  </form>
  </table>
  <!-- fim de FORMULÁRIO - ÁREAS DE INTERESSE -->
 
  
  </font>  </td>
</tr>
<tr>
  <td colspan="2" align="center">&nbsp;</td>
</tr>
<tr>
  <td colspan="2" align="center"  class="tit_grid">Minha Lista de Interesse</td>
</tr>

	<?php 
		$objRegistro  =  $objConn->Execute("SELECT 
											  tbl_curriculo_area_interesse.co_area_interesse,
											  tbl_curriculo_sub_area.no_area
											FROM
											  tbl_curriculo_sub_area
											  INNER JOIN tbl_curriculo_area_interesse 
											  ON (tbl_curriculo_sub_area.co_codigo = tbl_curriculo_area_interesse.co_area_interesse) 
											WHERE st_status='S'
											AND md5(co_cliente) = '". $_SESSION[md5('codigoUsuario')]."'
											ORDER BY no_area ASC");
		
		if( $objError->semErros() && $objRegistro->_numOfRows > 0)
		{
		    
			while( !$objRegistro->EOF ) { ?>
  <tr>
      <td width="23" align="left" valign="middle" bgcolor="#F8F8F8"><a href="?pg=area_de_interesse_form.php&<?php echo md5('actionRegistro').'='.md5( $objRegistro->fields['co_area_interesse'] ); ?>"><img src="images/icones/icone_excluir2.png" width="16" height="14" border="0"/></a></td>
    <td width="415" align="left" valign="middle" bgcolor="#F8F8F8"><?php echo $objRegistro->fields['no_area']; ?></td>
  </tr>

	<?php $objRegistro->MoveNext();
			}
		} else{
	?>
          <tr>
          <td width="23" align="left" valign="middle" bgcolor="#F8F8F8"></td>
        <td width="415" align="left" valign="middle" bgcolor="#F8F8F8">Nenhum interesse cadastrado.</td>
      </tr>    
<?php }?>
</table>
